package de.jabc.sib.bio.ebi;

import de.jabc.adapter.bio.ebi.Branches;
import de.jabc.adapter.bio.ebi.LightweightServiceAdapter;
import de.jabc.adapter.bio.ebi.ServiceAdapter;
import de.metaframe.jabc.framework.execution.ExecutionEnvironment;
import de.metaframe.jabc.framework.sib.annotation.SIBClass;
import de.metaframe.jabc.framework.sib.annotation.SIBStatus;
import de.metaframe.jabc.framework.sib.parameter.ContextExpression;
import de.metaframe.jabc.framework.sib.parameter.ContextKey;
import de.metaframe.jabc.sib.ServiceAdapterDescriptor;

/**
 * Calls the FetchBatch operation of the EBI's WSDBFetch web service.
 * 
 * @author anna-lena
 * @version $Revision: 3325 $ $Date: 2008-03-03 13:34:38 +0100 (Mon, 03 Mar 2008) $
 */
@SIBClass("ebi-sibs/WSDBFetch")
@SIBStatus("IMPLEMENTED")
public class WSDBFetch extends AbstractSIB {

	/* Branches */
	public static final String[] BRANCHES = { Branches.DEFAULT, Branches.ERROR };
	
	/* Parameters */
	public ContextExpression Database = new ContextExpression("", String.class, false);
	public ContextExpression ID = new ContextExpression("", String.class, false);
	public ContextExpression Format = new ContextExpression("", String.class, false);
	public ContextExpression Style = new ContextExpression("", String.class, false);
	
	public ContextKey result = new ContextKey("", ContextKey.Scope.LOCAL, true);
	
	
	

	/**
	 * @see de.metaframe.jabc.sib.CodeGeneratorBlock#execute(ExecutionEnvironment)
	 */
	public String execute(ExecutionEnvironment environment) {
		try {
			return ServiceAdapter.callWSDBFetch(environment, this.Database, this.ID, this.Format, this.Style, this.result);
		} catch (NoClassDefFoundError e) {
			return Branches.ERROR;
		}
	}

	/**
	 * @see de.metaframe.jabc.sib.Generatable#generate()
	 */
	public ServiceAdapterDescriptor generate() {
		return new ServiceAdapterDescriptor(LightweightServiceAdapter.class
				.getName(), "callWSDBFetch", "Database", "ID", "Format", "Style", "result");
	}

	
	
}
